function pdf()
{
$('#dostuff').click(function(){
    var email_address = $("#email_address").val(); 
    var password =  $("#password").val();

    var postData = {
      'email' : email_address,
      'password' : password,
      'html' : 'PASS'
    };

    $.post('/erp_invoice/insert', postData, function(data){
        //This should be JSON preferably. but can't get it to work on jsfiddle
        //Depending on what your controller returns you can change the action
        if (data == 'PASS') { 
            alert('login pased');
        } else {
            alert('login failed');
        }
    });
	
	    $.post('/erp_invoice/pdf_generate', postData, function(data){
        //This should be JSON preferably. but can't get it to work on jsfiddle
        //Depending on what your controller returns you can change the action
        if (data == 'PASS') { 
            alert('login pased');
        } else {
            alert('login failed');
        }
    });
});
  return false;
}

function maincalc() 
	{	
		var tmp1 = 0;
		var tmp2 = 0;
		var tbl = document.getElementById('items').tBodies[0];
		var lastRow = tbl.rows.length;
		var iter = lastRow;
		var rowCount = iter;
		//alert('LastRo:' + lastRow);
		//alert('rowCount' + iter);
		for(var rowIdx = 0; rowIdx < (rowCount); rowIdx++) 
			{
				x = 'items_rate' + rowIdx;
				//y = 'items_qty' + rowIdx;
				//z = 'items_prc' + rowIdx;
				tmp1 = document.getElementById(x).value;
				if(isNaN(tmp1))
					{
						alert('Rate\'s value should be a number.');
						break;
					}
				tmp1 = parseFloat(tmp1);	
				tmp2 = document.getElementById(y).value;
				if(isNaN(tmp2))
					{
					alert('Quantity value should be a number.');
					break;
					}
				tmp2 = parseFloat(tmp2);	
				tmp1 = tmp1*tmp2;
				tmp1 = parseFloat(tmp1);
				document.getElementById(z).value = tmp1;
				
			}
	}